<template>
  <div>
    <el-form label-width="120px">
      <h1>{{ tag2 }}股票</h1>
      <el-form-item label="证券代码">
        <el-input v-model="stock.code" placeholder="代码/简称" align="center"/>
      </el-form-item>
      <el-form-item label="证券名称">
        <el-input v-model="stock.name"/>
      </el-form-item>
      <el-form-item >
        <span slot="label">{{ tag1 }}(股)</span>
        <el-input v-model="stock.count"/>
      </el-form-item>
      <el-form-item label="价格">
        <el-input-number :min="0" v-model="stock.price"/>
      </el-form-item>
      <el-form-item>
        <span slot="label">{{ tag2 }}(股)</span>
        <el-input-number :min="0" v-model="stock.buyCount"/>
      </el-form-item>
      <el-form-item>
        <el-button :type="success" size="small" @click="buyOrSale">{{ tag2 }}</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  components: {

  },
  data() {
    return {
      success: 'success',
      tag1: '',
      tag2: '',
      stock: {
        code: '', // 证券代码
        name: '', // 证券名称
        count: '', // 可买股
        price: 11.4, // 价格
        buyCount: 0 // 买入股
      }
    }
  },
  created() {
    this.judge()
    this.stock = {}
  },
  methods: {
    judge() {
      if (this.$route.path === '/buy/index') {
        this.tag1 = '可买'
        this.tag2 = '买入'
        this.success = 'success'
      } else {
        this.tag1 = '可卖'
        this.tag2 = '卖出'
        this.success = 'warning'
      }
    },
    buyOrSale() {
      if (this.tag1 === '可买') {
        // TODO 买入
      } else {
        // TODO 卖出
      }
    }
  }
}

</script>
<style scoped>

</style>
